#include <stdio.h>

/* 0大端，1小端 */
int checkSystem() {
    union check {
        int i;
        char ch;
    } c;
    c.i = 1;
    return (c.ch == 1);
}

int IsBig_Endian()
//如果字节序为big-endian，返回true;
//反之为   little-endian，返回false
{
    unsigned short test = 0x1122;
    if (*( (unsigned char *) &test ) == 0x11)
        return 1;
    else
        return 0;

}//IsBig_Endian()

int main(int argc, char const *argv[]) {
    int result = checkSystem();
    printf("result is = %d\n", result);

    result = IsBig_Endian();
    printf("result2 is = %d\n", result);

    return 0;
}